﻿<div ms-controller="W_KCGL">
    <!-- 添加按钮 -->
    <div class="btn-add">
        <button type="button" class="btn btn-info btn-lg" ms-click="AddView('KCGL_KCGL')"><i class="iconfont icon-jiahao ft12 mr5"></i>添加课程</button>
    </div>
    <!-- 按条件选择 -->
    <div class="tab-filter-type">
        <div class="oh">
            <h5 class="pull-left tr">课程分类：</h5>
            <ul class="tab-type ft14">
                <li ms-click="SelectType('')"><span ms-class-1="active:kcflType==''">全部</span></li>
                <li ms-repeat-el="kcflData" ms-click="SelectType(el.ID)"><span ms-class="active:el.ID==kcflType">{{el.TypeName}}</span></li>
            </ul>
        </div>
        <!-- 搜索 -->
        <div class="oh">
            <div class="input-group ml15" style="width:295px;">
                <input type="search" class="form-control" ms-duplex="search.searchcontent" placeholder="搜索课程管理名称">
                <span class="input-group-addon" ms-click="GetLIST()">搜索</span>
            </div>
        </div>
    </div>
    <!-- 展开更多选项 -->
    <div class="add-tab ft14 tc mt20" style="display:none;">
        <span>更多筛选<i class="caret"></i></span>
    </div>
    <!-- 按条件选择 -->
    <!-- 表格 -->
    <div class="default-tab ft14 pt20 hover-btn">
        <table class="table table-striped table-responsive table-hover">
            <thead>
                <tr>
                    <th class="tc">序号</th>
                    <th>
                        专业分类
                    </th>
                    <th>培训课程名称</th>
                    <th>主讲人姓名</th>
                    <th>课时数(小时)</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <tr ms-repeat-el="ListData">
                    <td class="tc">
                        {{$index+1+page.pagecount*(page.pageindex-1)}}
                    </td>
                    <td>{{el.TypeName}}</td>
                    <td>{{el.KCName}}</td>
                    <td>{{el.KCZJR}}</td>
                    <td>{{el.KSS }}</td>
                    <td>
                        <span class="btn-click">
                            <a class="cz-btn ft18 bj-color tip" data-toggle="tooltip" title="编辑" ms-click="AddView('KCGL_KCGL','课程编辑',el.ID,$event)">
                                <i class="iconfont icon-bianji"></i>
                            </a>
                            <a class="cz-btn ft18 sc-color tip" data-toggle="tooltip" title="查看" ms-click="KCView(el.ID)">
                                <i class="iconfont icon-look"></i>
                            </a>
                            <a class="cz-btn ft18 sc-color tip" data-toggle="tooltip" title="删除" ms-click="DELKCGL(el,event)">
                                <i class="iconfont icon-shanchu"></i>
                            </a>
                        </span>
                    </td>
                </tr>

            </tbody>
            <tfoot>
                <tr ms-if="isnull"><td class="tc"></td><td>暂无数据</td></tr>
            </tfoot>
        </table>
        <div class="ui-datatable-page ft14 pl20">

            <div id="pageDiv" ms-visible="model.page.total>model.pageNum[0].num" class="pull-right"></div>
            <div class="pull-right" ms-visible="ListData.size()!=0">
                <span>共{{model.page.total}}条记录</span>
                <span ms-visible="model.page.total>model.pageNum[0].num">
                    选择每页条数
                    <select style="height: 25px; width: 50px;" ms-change="selNum(this.value)" ms-duplex="model.page.pagecount">
                        <option ms-repeat-pg="pageNum" ms-attr-value="pg.num" ms-attr-selected="pg.num==model.page.pagecount?'selected':''">{{pg.num}}</option>
                    </select>
                </span>
            </div>

        </div>
    </div>


</div>

<script>
    var tempindex = avalon.define({
        $id: "W_KCGL",
        kcflData: [],
        userName: ComFunJS.getnowuser(),
        kcflType: "",
        InitWigetData: function (str) {
            $.getJSON('/API/VIEWAPI.ashx?Action=XTGL_GETZIDIANLIST', { P1: 24 }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    tempindex.kcflData = resultData.Result;

                }
            })
            tempindex.GetLIST();

        },
        SelectType: function (type) {
            tempindex.kcflType = type;
            tempindex.GetLIST();
        },
        KCView: function (Id) { 
            ComFunJS.winviewform("/ViewV5/AppPage/KCGL/KCINFO.html?id=" + Id, '课程查看详细', "1100", "700")
        },
        GetLIST: function () {
            $.getJSON('/API/VIEWAPI.ashx?Action=KCGL_GETKCGLLIST', { p: 1, P1: tempindex.kcflType, Content: model.search.searchcontent, pagecount: model.page.pagecount }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    model.ListData = resultData.Result;
                    model.page.total = resultData.Result1;
                    if (model.ListData.size() == 0) { model.isnull = true; } else { model.isnull = false; }
                    laypage({
                        cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                        pages: Math.ceil(parseInt(resultData.Result1) * 1.0 / model.page.pagecount), //通过后台拿到的总页数
                        curr: 1, //初始化当前页
                        skin: 'molv',
                        jump: function (e) { //触发分页后的回调
                            if (e.curr != model.page.pageindex) {
                                $.getJSON('/API/VIEWAPI.ashx?Action=KCGL_GETKCGLLIST', { p: e.curr, P1: tempindex.kcflType, Content: model.search.searchcontent, pagecount: model.page.pagecount }, function (resultData) {
                                    if (resultData.ErrorMsg == "") {
                                        model.ListData = resultData.Result;
                                    }
                                })
                                model.page.pageindex = e.curr;
                            }
                        }
                    });
                }
            })
        },
        DELKCGL: function (item, event) {
            if (event) {
                event.stopPropagation();
            }
            top.ComFunJS.winconfirm("确认要删除此课程吗？", function () {
                $.post('/API/VIEWAPI.ashx?Action=KCGL_DELKCGLBYID', { "P1": item.ID }, function (result) {
                    result = JSON.parse(result)
                    if (result.ErrorMsg == "") {
                        top.ComFunJS.winsuccess("删除成功");
                        model.ListData.remove(item);
                    } else {
                        top.ComFunJS.winwarning(result.ErrorMsg);
                    }
                })
            }, function () { })
        },
    })//@ sourceURL=KCGLLSIT.js;


</script>
